<template>
	<view class="content">
		<view class="list">
			<view 
				class="item u-p-30 u-flex u-border-bottom"
				v-for="(item, index) in list"
				:key="index"
				@click="toEdit(item)">
				<view class="item-left u-flex-1">
					<view class="item-title u-font-32">保利(单交)</view>
					<view class="u-flex u-tips-color u-font-30 u-m-t-10">
						<text>交强：20</text>
						<text class="u-m-l-20">税：20</text>
						<text class="u-m-l-20">商业：20</text>
						<text class="u-m-l-20">驾乘：20</text>
					</view>
				</view>
				<view class="item-right u-flex">
					<view>
						<u-icon
							name="edit-pen-fill" 
							color="#666" 
							size="26"></u-icon>
					</view>
					<view class="u-m-l-20" @click.stop>
						<u-icon
							name="trash-fill" 
							color="#666" 
							size="26"
							@click="onDelete(item, index)"></u-icon>
					</view>
				</view>
			</view>
		</view>
		
		<view class="addBox">
			<u-icon
				name="plus-circle-fill"
				color="#005aba"
				size="50"
				@click="toEdit"></u-icon>
		</view>
		
		<u-modal 
			:show="showModal" 
			:title="title" 
			:content="description"
			@cancel="showModal = false" 
			@confirm="confirm" 
			ref="uModal" 
			:asyncClose="true"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
						name: '保利(单交)',
						jq: 20,
						tax: 30,
						bus: 40,
						drive: 10
					},
					{
						name: '保利(单交)',
						jq: 20,
						tax: 30,
						bus: 40,
						drive: 10
					},
					{
						name: '保利(单交)',
						jq: 20,
						tax: 30,
						bus: 40,
						drive: 10
					}
				],
				showModal: false,
				title: '温馨提醒',
				description: ''
			}
		},
		onShow() {
			// 权限跳转
			// let date = new Date()
			// let year = date.getFullYear()
			// let month = (date.getMonth() + 1 < 10 ? '0'+ (date.getMonth() + 1) : date.getMonth() + 1)
			// let day = (date.getDate() < 10 ? '0'+ date.getDate() : date.getDate())
			// let d = year + '-' + month + '-' + day
			// if (d == '2024-01-17') {
			// 	uni.navigateTo({
			// 		url: '/pages/error/error'
			// 	})
			// }
		},
		onReady() {
		},
		methods: {
			openDetail(url) {
				uni.navigateTo({
					url
				})
			},
			toEdit() {
				// this.openDetail('/pages/insure/edit')
			},
			onDelete(item, index) {
				this.showModal = true
				this.description = '您确定删除该条信息吗？'
				this.index = index
			},
			confirm() {
				this.$nextTick(() => {
					this.list.splice(this.index, 1)
					this.showModal = false
				}, 1000)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 0 0 160rpx;
	}
	.addBox {
		position: fixed;
		right: 40rpx;
		bottom: 60rpx;
	}
</style>
